from flask import Flask, render_template, jsonify
from handles.getdata import *
from handles.getdata import h_task2
import settings
from flask_cors import CORS


app = Flask(__name__)
app.config.from_object(settings)
CORS(app)

# 数据接口
@app.route('/')
def index():
    return render_template('datas.html')

# ---------------------------------左上 柱状图 -----------------------------------------------------------------
@app.route('/task1', methods=['GET'])
def task1():
    data = h_task1()
    return jsonify(data)


# ---------------------------------左中 条形图-------------------------------------------------------------------
@app.route('/task2', methods=['GET'])
def task2():
    return jsonify(h_task2())

# ---------------------------------左下 瀑布图 -------------------------------------------------------------------
@app.route('/task3', methods=['GET'])
def task3():
    data = h_task3()
    return jsonify(data)

# ---------------------------------中上 折线图 -------------------------------------------------------------------
@app.route('/task4', methods=['GET'])
def task4():
    data = h_task4()
    return jsonify(data)

# --------------------------------- 中中 雷达图-------------------------------------------------------------------
@app.route('/task5', methods=['GET'])
def task5():
    data = h_task5()
    return data
#
# # --------------------------------- 中下 玫瑰图-------------------------------------------------------------------
@app.route('/task6', methods=['GET'])
def task6():
    data = h_task6()
    return jsonify(data)
#
# --------------------------------- 右上 环形图-------------------------------------------------------------------
@app.route('/task7', methods=['GET'])
def task7():
    data = h_task7()
    return jsonify(data)

#--------------------------------- 右中 旭日图-------------------------------------------------------------------
@app.route('/task8')
def task8():
    data = h_task8()
    return jsonify(data)

# --------------------------------- 右下 树图-------------------------------------------------------------------
@app.route('/task9')
def task9():
    data = h_task9()
    return jsonify(data)

if __name__ == '__main__':
    app.run(threaded=True,port=5002,host='0.0.0.0')
